var PostDetails = {
	article_id: fnBase.splitURL()['article_id'],
	user_id: fnBase.splitURL()['user_id'],
	user_name: fnBase.splitURL()['user_name'],
	user_img: fnBase.splitURL()['user_img'],
	page: 1,
	replyThis:{},
	//hackBug: true,
	//初始化事件
	init: function() {
		this.getArticleInfo(); //帖子内容
		this.AddEvent(); //事件
		this.forAddEvent();
		//this.arriveBottom();
		//this.myLiuCommenList();
	},
	//初始化点击事件委托
	initClick: function(e) {
		var list = document.getElementById('postcont_list');
		var boxs = list.children;
		var boxsLength = boxs.length;
		for(var i = 0; i < boxsLength; i++) {
			boxs[i].onclick = function(e) {
				e = e || window.event;
				var el = e.srcElement ? e.srcElement : e.target;
				switch(el.className) {
					case 'imgto-individual':
						//点评论头像去个人简介
						PostDetails.goIndividual(el);
						break;
					case 'nameto-individual':
						//点名字去个人
						PostDetails.goIndividual(el);
						break;
					case 'replynick-go-individual':
						//被回复昵称去个人
						PostDetails.goIndividual(el);
						break;
					case 'nick-go-individual':
						//回复昵称去个人
						PostDetails.goIndividual(el);
						break;
					case 'second-reply':
						//三级回复
						PostDetails.setUpTextareaBox(el);
						break;
					case 'post-comments-txt':
						//二级回复
						PostDetails.setUpTextareaBox(el);
						break;
					
				}
			};
		}
	},
	
	//获取帖子内容
	getArticleInfo: function() {
		var loadingMask = document.getElementById('cssload');
		var BoxWrap = document.getElementById('pullrefresh');
		var oInput= document.getElementById('post_input');		
		$.ajax({
			type: "POST",
			url: fnBase.api.post_ArticleInfo,
			dataType: "JSON",
			data: {
				"article_id": PostDetails.article_id, //文章ID
				"user_id": PostDetails.user_id,
			},
			success: function(data) {
				//console.log(data);
				if(data.code == 0) {
					
					var datal = data.data;
					var user = data.data.user;
					var articleImg = data.data.img;
					var str = '',
						comNum = '',
						img = '',
						ImgWrap = '',
						imgs = '';
					var collect = datal.is_collect == 1 ? '<li class="add-collect-after"><img src="images/major-collect.png"/></li>' : '<li class="add-collect"><img src="images/collect.png"/></li>';
					var top = datal.top == 1 ? '<img class="post-top-ding" src="images/ding@2x.png"/>' : '';
					var very = datal.very == 1 ? '<img class="post-top-jing" src="images/jing@2x.png"/>' : '';
					var isLaud = datal.is_laud == 1 ? '<img class="addLaud" src="images/d-like.png"/>' : '<img class="addLaud" src="images/d-like-After.png"/>';
					if(fnBase.isLogin(user.img)) {
						img = '<img src="' + user.img + '" />';
					} else {
						img = '<img src="images/user_img.png"/>';
					}
					var ErrorImg='images/error_img.png';
					if(articleImg != '' && articleImg.length!=1) {
						for(var k = 0; k < articleImg.length; k++) {
							imgs += '<div class="article-imgBox"><img src="' + articleImg[k] + '" onerror="javascript:this.src=&quot;images/error_img.png&quot;;"  onload="PostDetails.DrawImage_box(this)"/></div>';
						}
						ImgWrap = '<ul id="data-preview-banner" class="post-center-banner">' + imgs + '</ul>';
					} else if(articleImg.length==1){
						imgs = '<div ><img src="' + articleImg + '" onerror="javascript:this.src=&quot;images/error_img.png&quot;;"/></div>';
						ImgWrap = '<ul id="data-preview-banner" class="post-center-oneimg">' + imgs + '</ul>';
					}else{
						ImgWrap = '<ul></ul>';
					}
					str = '<ul  class="post-top-user">' +
						'<li id="getuser" class="userimg-toquan" user_id="' + user.id + '">' + img + '</li>' +
						'<li><p class="username-toquan" user_id="' + user.id + '">' + user.nick + '</p><p>' + user.prov_name + '&nbsp;' + user.subject + '&nbsp;' + user.type + '</p></li>' +
						'</ul>' +
						'<dl class="post-top-title">' + top + '' + very + '' + datal.title + '</dl>' +
						'<ul class="post-top-gai"><li>' + datal.add_time + '</li><li>来自&nbsp;<span class="go-circle" data_circle_id="'+datal.circle_id+'">'+datal.circle_name+'</span></li><li class="post-page-view"><img src="images/read.png"/> ' + datal.assess + '</li></ul>'+
						'<div id="postcenter" class="post-center-txt">' +
						'<li>' + datal.content + '</li></div>' + ImgWrap +
						'<dl class="post-center-praised">' +
						'<dt>' + isLaud + '</dt>' +
						'<dd><span id="laudnum">' + datal.laud + '</span>&nbsp;人点赞</dd></dl>';
					comNum = '<li class="post-commentnum">回复(' + datal.reply + ')</li>';
					$('.post-cont-nav').html(comNum);
					$('#postTop').append(collect);
					$('#postContBox').html(str);
					loadingMask.parentNode.removeChild(loadingMask);
					BoxWrap.style.display = "block";
					oInput.style.display="block";
					mui.previewImage();//图片
				
					
				} else {
					fnBase.toast(data.msg);
					loadingMask.parentNode.removeChild(loadingMask);
					fnBase.deletetext();
					BoxWrap.style.display = "none";
					oInput.style.display="none";
				}

			},
			error: function() {
				fnBase.toast('网络不通畅');
				loadingMask.parentNode.removeChild(loadingMask);
				fnBase.linkError();
				BoxWrap.style.display = "none";
				oInput.style.display="none";
			},

		});
	},
	//图片处理
	DrawImage_box:function(ImgID){
		var ImgID=ImgID;
		var imgBox=ImgID.parentNode;
		var h = imgBox.offsetHeight;  //高度
		var w = imgBox.offsetWidth;  //宽度
		DrawImage(ImgID,w,h);
		//图片缩放居中核心功能
		function DrawImage(ImgID, width_s, height_s) {
			//console.log(ImgID,width_s,height_s)
	    	var myImage = new Image();
	   		myImage.src = ImgID.src;
	    	if (myImage.width > 0 && myImage.height > 0) {
	       		flag = true;
	        	if (myImage.width / myImage.height <= width_s / height_s) {
	       			ImgID.width = width_s;
	           		var height = (myImage.height * width_s) / myImage.width;
	            	ImgID.height = height;
	            	ImgID.style.marginTop = -(height - height_s)/2 + "px";
	        	} else {
	            	ImgID.height = height_s;
	            	var width = (myImage.width * height_s) / myImage.height;
	            	ImgID.width = width;
	            	ImgID.style.marginLeft = -(width - width_s)/2 + "px";
	        	}
	    	}
		}
	},
	AddEvent: function() {
		//点击返回
		$('#goBack').on('click',function() {
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				GoBack();
			} else if(fnBase.versions.android) {
				window.myObj.goBack();
			}
		});
		//跳转原生圈子
		$('#postContBox').on('click','.go-circle',function(){
			var nowTime = new Date().getTime();
			var myThis = $(this);
			var clickTime = myThis.attr("ctime");
			if(clickTime != 'undefined' && (nowTime - clickTime < 5000)) {
				return false;
			} else {
				myThis.attr("ctime", nowTime);
			}
			var circle_id=myThis.attr('data_circle_id');
			//console.log(circle_id);
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				if(!fnBase.isLogin(PostDetails.user_id)) {
					GoToLogin();
					return false;
				};
				GoToCircleDetailInfo(circle_id);
			} else if(fnBase.versions.android) {
				window.myObj.toCircleHome(circle_id);
			}
		});
		//点击分享大分享
		$('#btn_share').on('click',function(){
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
					showShareBoard();
			} else if(fnBase.versions.android) {
					window.myObj.Share();
			}
		});
		//点赞
		$('#postContBox').on('click', '.addLaud', function() {
			if(!fnBase.isLogin(PostDetails.user_id)) {
				//fnBase.toast('亲！您未登陆');
				if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
					GoToLogin();
				} else if(fnBase.versions.android) {
					window.myObj.toLogin();
				}
				return false;
			};
			var _this = $(this);
			var sendData = {
				"user_id": PostDetails.user_id,
				"article_id": PostDetails.article_id
			};
			fnBase.commonAjax(fnBase.api.post_ArticleLaud, sendData, function(data) {
				if(data.code == 0) {
					_this.attr("src", "images/d-like.png");
					var zanNum = parseInt($('#laudnum').html()) + 1;
					$('#laudnum').html(zanNum);
					var oBox = document.createElement('p');
					oBox.className = 'special_effects';
					oBox.style.display = 'block';
					oBox.innerHTML = '+1';
					_this.parent().append(oBox);
					oBox.addEventListener('webkitAnimationEnd', onOff);

					function onOff() {
						oBox.style.display = 'none';
					}
				} else {

					fnBase.toast(data.msg);
				}
			});
		});
		//收藏
		$('#postTop').on('click', '.add-collect', function() {
			if(!fnBase.isLogin(PostDetails.user_id)) {
				//fnBase.toast('亲！您未登陆');
				if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
					GoToLogin();
				} else if(fnBase.versions.android) {
					window.myObj.toLogin();
				}
				return false;
			};
			var _this = $(this);
			var sendData = {
				"user_id": PostDetails.user_id,
				"article_id": PostDetails.article_id
			};
			fnBase.commonAjax(fnBase.api.post_ArticleCollect, sendData, function(data) {
				if(data.code == 0) {
					_this.removeClass('add-collect').addClass('add-collect-after');
					_this.html('<img src="images/major-collect.png"/>');
					fnBase.toast('收藏成功');
				}
			});
		});
		$('#postTop').on('click', '.add-collect-after', function() {
			if(!fnBase.isLogin(PostDetails.user_id)) {
				//fnBase.toast('亲！您未登陆');
				if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
					GoToLogin();
				} else if(fnBase.versions.android) {
					window.myObj.toLogin();
				}
				return false;
			};
			var _this = $(this);
			var sendData = {
				"user_id": PostDetails.user_id,
				"article_id": PostDetails.article_id
			};
			fnBase.commonAjax(fnBase.api.post_ArticleCollectCancel, sendData, function(data) {
				if(data.code == 0) {
					_this.removeClass('add-collect-after').addClass('add-collect');
					_this.html('<img src="images/collect.png"/>');
					fnBase.toast('取消收藏');
				}
			});
		});
		//点头像跳转事件
		$('#postContBox').on('click', '.username-toquan', function() { //点名字去跳转
			var _this = $(this);
			PostDetails.goIndividual(_this);
		});
		$('#postContBox').on('click','.userimg-toquan', function() {
			var _this = $(this);
			PostDetails.goIndividual(_this);
		});
		
		//唤起真输入框并隐藏假输入框
		$('#arouse_input').on('click', function() {
			var el = $(this);
			PostDetails.setUpTextareaBox(el);
		});
		//点沙发唤起输入框
		$('#notcom').on('click', function() {
			var el = $(this);
			PostDetails.setUpTextareaBox(el);
		});
		$('.post-share-weixin').on('click',function() {
			var nowTime = new Date().getTime();
			var myThis = $(this);
			var clickTime = myThis.attr("ctime");
			if(clickTime != 'undefined' && (nowTime - clickTime < 5000)) {
				fnBase.toast('操作过于频繁，稍后再试');
				return false;
			} else {
				myThis.attr("ctime", nowTime);
			}
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				sharedToWechat();
			} else if(fnBase.versions.android) {
				window.myObj.ShareWeixin();
			}
		});
		$('.post-share-Timeline').on('click',function() {
			var nowTime = new Date().getTime();
			var myThis = $(this);
			var clickTime = myThis.attr("ctime");
			if(clickTime != 'undefined' && (nowTime - clickTime < 5000)) {
				fnBase.toast('操作过于频繁，稍后再试');
				return false;
			} else {
				myThis.attr("ctime", nowTime);
			}
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				sharedToWechatTimeLine();
			} else if(fnBase.versions.android) {
				window.myObj.ShareWeixinCircle();
			}

		});
		$('.post-share-weibo').on('click',function() {
			var nowTime = new Date().getTime();
			var myThis = $(this);
			var clickTime = myThis.attr("ctime");
			if(clickTime != 'undefined' && (nowTime - clickTime < 5000)) {
				fnBase.toast('操作过于频繁，稍后再试');
				return false;
			} else {
				myThis.attr("ctime", nowTime);
			}
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				sharedToWeibo();
			} else if(fnBase.versions.android) {
				window.myObj.ShareSina();
			}
		});
		$('.post-share-Zone').on('click',function() {
			var nowTime = new Date().getTime();
			var myThis = $(this);
			var clickTime = myThis.attr("ctime");
			if(clickTime != 'undefined' && (nowTime - clickTime < 5000)) {
				fnBase.toast('操作过于频繁，稍后再试');
				return false;
			} else {
				myThis.attr("ctime", nowTime);
			}
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				sharedToQQZone();
			} else if(fnBase.versions.android) {
				window.myObj.ShareZone();
			}
		});
		$('.post-share-qq').on('click',function() {
			var nowTime = new Date().getTime();
			var myThis = $(this);
			var clickTime = myThis.attr("ctime");
			if(clickTime != 'undefined' && (nowTime - clickTime < 5000)) {
				fnBase.toast('操作过于频繁，稍后再试');
				return false;
			} else {
				myThis.attr("ctime", nowTime);
			}
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				sharedToQQ();

			} else if(fnBase.versions.android) {
				window.myObj.ShareQQ();
			}
		});

	},
	//多次事件
	forAddEvent: function() {
		//评论点赞
		$('#postcont_list').bind('click').on('click', '.praise-btn', function() {
			var _this = $(this);
			PostDetails.CommentsAddLaud(_this);
		});
		//点回复数 评论
		$('#postcont_list').bind('click').on('click', '.comment-btn', function() {
			var el = $(this);
			PostDetails.setUpTextareaBox(el);
		});
		$('#postcont_list').bind('click').on('click', '.post-comments-function', function() {
			var _this = $(this);
			PostDetails.commentsReply(_this);
		});
	},
	//文章回复评论内容
	myLiuCommenList: function() {
		var URL = fnBase.api.post_ArticleReplayInfo;
		//console.log(PostDetails.page);
		var sendData = {
			"article_id": PostDetails.article_id,
			"user_id": PostDetails.user_id,
			"page": PostDetails.page,
		}
		fnBase.commonAjax(URL, sendData, function(data) {
			var $comment = data.data;
			if($comment.length != 0) {
				for(var i = 0; i < $comment.length; i++) {
					var reply = $comment[i].reply.data;
					var twocommentStr = '',
						Img = '';
					if(reply !== null && reply.length) {
						for(var k = 0; k < reply.length; k++) {
							// 回复一楼第一状态2-1 名：user_id!=被回复user_id 同时，父几id相等;//一楼回复自己  第三状态 1-1 名 user_id =被回复user_id 父几id相等
							if(reply[k].reply_user_id == $comment[i].user.id && reply[k].parent_id == $comment[i].id) {
								twocommentStr += '<div class="post-comments-child">' +
									'<p source_id="3" user_name="' + reply[k].nick + '" user_id="' + reply[k].user_id + '" article_reply_id="' + $comment[i].id + '" class="second-reply"><span class="nick-go-individual" user_id="' + reply[k].user_id + '">' + reply[k].nick + '：</span>' +
									reply[k].content + '</p>' +
									'</div>';
								//一楼回复二楼  第二状态 1-2 回名 user_id!=被回复user_id 父userid =user_id;
							} else if(reply[k].user_id == $comment[i].user.id && reply[k].parent_id != $comment[i].id) {
								twocommentStr += '<div class="post-comments-child">' +
									'<p source_id="3" user_name="' + reply[k].nick + '" user_id="' + reply[k].user_id + '" article_reply_id="' + $comment[i].id + '" class="second-reply"><span class="spancolor">回复</span>' +
									'<span user_id="' + reply[k].reply_user_id + '" class="replynick-go-individual">' + reply[k].reply_nick + '：</span>' +
									reply[k].content + '</p>' +
									'</div>';

							} else {
								//其他回复二楼 第四状态3-2 名回明
								twocommentStr += '<div class="post-comments-child">' +
									'<p source_id="3" user_name="' + reply[k].nick + '" user_id="' + reply[k].user_id + '" article_reply_id="' + $comment[i].id + '" class="second-reply"><span user_id="' + reply[k].user_id + '"  class="nick-go-individual">' + reply[k].nick + '</span>' +
									'<span class="spancolor">回复</span><span user_id="' + reply[k].reply_user_id + '" class="replynick-go-individual">' + reply[k].reply_nick + '：</span>' +
									reply[k].content + '</p>' +
									'</div>';
							}
						}
					}
					if(fnBase.isLogin($comment[i].user.img)) {
						Img = $comment[i].user.img;
					} else {
						Img = 'images/user_img.png';
					}
					var myBorder=(reply !== null && reply.length)?'com-bor':'';
					var isLaud = $comment[i].is_laud == 1 ? '<img src="images/icon-zan-After.png"/>' : '<img src="images/icon-zan.png"/>';
					var moreReplyPlus = $comment[i].reply.plus > 0 ? '<ul page="1" user_id="' + $comment[i].user.id + '" article_reply_id="' + $comment[i].id + '" class="post-comments-function"><li class="comments-Reply">更多<span>' + $comment[i].reply.plus + '</span>条评论</li></ul>' : '';
					var $commentStr = '<div class="post-cont">' +
						'<ul class="post-cont-user"><li><img user_id="' + $comment[i].user.id + '" class="imgto-individual" src="' + Img + '"/></li>' +
						'<li><p user_id="' + $comment[i].user.id + '" class="nameto-individual">' + $comment[i].user.nick + '</p><p>' + $comment[i].add_time + '</p></li>' +
						'<li source_id="2" user_name="' + $comment[i].user.nick + '" user_id="' + $comment[i].user.id + '" article_reply_id="' + $comment[i].id + '"  class="comment-btn"><img src="images/icon-groupcopy.png"/><span>' + $comment[i].reply.count + '</span></li>' +
						'<li article_reply_id="' + $comment[i].id + '"  class="praise-btn">' + isLaud + '<span>' + $comment[i].laud + '</span></li></ul>' +
						'<div class="mymargin"><li article_reply_id="' + $comment[i].id + '" source_id="2" user_name="' + $comment[i].user.nick + '"  user_id="' + $comment[i].user.id + '" class="post-comments-txt">' + $comment[i].content + '</li>' +
						'<li class="post-comments-child-wrap  '+myBorder+'">' +
						twocommentStr +
						'</li>' + moreReplyPlus + '</div></div>';
					$('#postcont_list').append($commentStr);
				}
				PostDetails.initClick();
				PostDetails.page++;
				//PostDetails.noMoreLoading();
				mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
				//console.log(PostDetails.page);
			} else {
				if(PostDetails.page == 1) {
					PostDetails.page++;
					$('#notcom').show();
				}
				//PostDetails.hackBug = false;
				//PostDetails.noMoreLoading();
				mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
			}
		});
	},
	//更多二级评论
	commentsReply: function(_this) {
		var article_reply_id = _this.attr('article_reply_id');
		var page = _this.attr('page');
		var user_id = _this.attr('user_id');
		var URL = fnBase.api.post_ArticleReplyMore;
		var sendData = {
			'id': article_reply_id,
			'page': page
		}
		fnBase.commonAjax(URL, sendData, function(data) {
			if(data.code == 0) {
				if(data.data.plus >= 0) {
					var reply = data.data.data;
					var twocommentStr = '';
					for(var k = 0; k < reply.length; k++) {
						// 回复一楼第一状态2-1 名：ru==pu 同时，父几id相等;//一楼回复自己  
						if(reply[k].reply_user_id == user_id && reply[k].parent_id == article_reply_id) {
							twocommentStr += '<div class="post-comments-child">' +
								'<p source_id="3" user_name="' + reply[k].nick + '" user_id="' + reply[k].user_id + '" article_reply_id="' + reply[k].parent_id + '" class="second-reply"><span class="nick-go-individual" user_id="' + reply[k].user_id + '">' + reply[k].nick + '：</span>' +
								reply[k].content + '</p>' +
								'</div>';

							//一楼回复二楼  第二状态 1-2 回名 user_id!=被回复user_id 父userid =user_id;
						} else if(reply[k].user_id == user_id && reply[k].parent_id != article_reply_id) {
							twocommentStr += '<div class="post-comments-child">' +
								'<p source_id="3" user_name="' + reply[k].nick + '" user_id="' + reply[k].user_id + '" article_reply_id="' + reply[k].parent_id + '" class="second-reply"><span class="spancolor">回复</span>' +
								'<span user_id="' + reply[k].reply_user_id + '" class="replynick-go-individual">' + reply[k].reply_nick + '：</span>' +
								reply[k].content + '</p>' +
								'</div>';
							//console.log(twocommentStr);
							//其他回复二楼 第四状态3-2 名回明
						} else {
							twocommentStr += '<div class="post-comments-child">' +
								'<p source_id="3" user_name="' + reply[k].nick + '" user_id="' + reply[k].user_id + '" article_reply_id="' + reply[k].parent_id + '" class="second-reply"><span user_id="' + reply[k].user_id + '"  class="nick-go-individual">' + reply[k].nick + '</span>' +
								'<span class="spancolor">回复</span><span user_id="' + reply[k].reply_user_id + '" class="replynick-go-individual">' + reply[k].reply_nick + '：</span>' +
								reply[k].content + '</p>' +
								'</div>';
							//console.log(twocommentStr);
						}

						//console.log(twocommentStr)
					}
					_this.prev().append(twocommentStr);
					page++
					_this.attr('page', page);
					var plus = data.data.plus == 0 ? '' : '更多<span>' + data.data.plus + '</span>条评论';
					_this.find('li').html(plus);
					if(data.data.plus == 0) {
						_this.remove();
					}

				} else {
					_this.remove();
				}

			}
		});

	},
	//与原生交互去个人页面
	goIndividual: function(el) {
		var _this = $(el);
		var nowTime = new Date().getTime();
		var clickTime = _this.attr("ctime");
		if(clickTime != 'undefined' && (nowTime - clickTime < 5000)) {
			return false;
		} else{
			_this.attr("ctime", nowTime);
		}
		//fnBase.toast('跳个人');
		var user_id = _this.attr('user_id');
		user_id = parseInt(user_id);
		if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
			GoToUserDetailInfo(user_id);
		} else if(fnBase.versions.android) {
			window.myObj.IntentSelfCenter(user_id);
		}

	},
	//评论点赞
	CommentsAddLaud: function(_this) {
		var article_reply_id = _this.attr('article_reply_id');
		if(!fnBase.isLogin(PostDetails.user_id)) {
			//fnBase.toast('亲！您未登陆');
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				GoToLogin();
			} else if(fnBase.versions.android) {
				window.myObj.toLogin();
			}
			return false;
		};
		var URL = fnBase.api.post_ArticleReplyLaud;
		var sendData = {
			"article_reply_id": article_reply_id,
			"user_id": PostDetails.user_id
		};
		fnBase.commonAjax(URL, sendData, function(data) {
			if(data.code == 0) {
				_this.children('img').attr("src", "images/icon-zan-After.png");
				_this.children('img').addClass('scaleMagnify');
				var zanNum = parseInt(_this.children('span').html()) + 1;
				_this.children('span').html(zanNum);
			} else {
				fnBase.toast(data.msg)
			}
		});
	},
	//获取原生参数内容
	getTextareaBox:function(source,parent_id,reply_user_id,reply_user_name,contentVal){
		var contentVal=contentVal;
		var source=source;
		var parent_id =parent_id;
		var reply_user_id=reply_user_id;
		var reply_user_name=reply_user_name;
		var _this=PostDetails.replyThis;
		var content = contentVal;
		content = content.replace(/\n/g, "<br/>");
		content = content.replace(/\s/g, "&nbsp;");
		console.log(source, parent_id, content, reply_user_id);
		//article_id 文章ID ，parent_id 父级ID（1级回复默认为0） content user_id 
		//reply_user_id 被回复者ID（1级回复默认为文章用户ID）
		var URL = fnBase.api.post_ArticleReplyAdd;
		var sendData = {
			'article_id': PostDetails.article_id,
			'parent_id': parent_id,
			'content': content,
			'user_id': PostDetails.user_id,
			'reply_user_id': reply_user_id
		};
		fnBase.commonAjax(URL,sendData,function(data) {
			if(data.code == 0) {
				var str = '';
				var callback_id = data.data.id;
				if(source == 1) {
					str = '<div class="post-cont">' +
							'<ul class="post-cont-user"><li><img user_id="' + PostDetails.user_id + '" class="imgto-individual" src="' + PostDetails.user_img + '"/></li>' +
							'<li><p user_id="' + PostDetails.user_id + '" class="nameto-individual">' + PostDetails.user_name + '</p><p class="p-mar-hei">刚刚</p></li>' +
							'<li source_id="2" user_id="' + PostDetails.user_id + '" user_name="' + PostDetails.user_name + '" article_reply_id="' + callback_id + '"  class="comment-btn"><img src="images/icon-groupcopy.png"/><span>0</span></li>' +
							'<li article_reply_id="' + callback_id + '"  class="praise-btn"><img src="images/icon-zan.png"/><span>0</span></li></ul>' +
							'<div class="mymargin"><li article_reply_id="' + callback_id + '" source_id="2" user_name="' + PostDetails.user_name + '" user_id="' + PostDetails.user_id + '" class="post-comments-txt">' + content + '</li>' +
							'<li class="post-comments-child-wrap"></li></div></div>';
						$('#postcont_list').prepend(str);
						PostDetails.initClick();
						$('#notcom').hide();
					} else if(source == 2) {
						str = '<div class="post-comments-child">' +
							'<p source_id="3" user_name="' + PostDetails.user_name + '" user_id="' + PostDetails.user_id + '" article_reply_id="' + parent_id + '" class="second-reply"><span user_id="' + PostDetails.user_id + '"  class="nick-go-individual">' + PostDetails.user_name + '</span>' +
							'<span class="spancolor">回复</span><span user_id="' + reply_user_id + '" class="replynick-go-individual">' + reply_user_name + '：</span>' +
							content + '</p></div>';
						var myLi = _this.parent().parent().find('.post-comments-child-wrap');
						myLi.append(str);
						PostDetails.initClick();
						
					} else {
						//三级回复
						str = '<div class="post-comments-child">' +
							'<p source_id="3" user_name="' + PostDetails.user_name + '" user_id="' + PostDetails.user_id + '" article_reply_id="' + parent_id + '" class="second-reply"><span user_id="' + PostDetails.user_id + '"  class="nick-go-individual">' + PostDetails.user_name + '</span>' +
							'<span class="spancolor">回复</span><span user_id="' + reply_user_id + '" class="replynick-go-individual">' + reply_user_name + '：</span>' +
							content + '</p></div>';
						_this.parent().parent().append(str);
						PostDetails.initClick();
					}
				} else {
					fnBase.toast(data.msg);
					//$('#post_input').show();
				}
			});
	},	
	//真输入框
	setUpTextareaBox: function(el) { //输入框盒子
		if(!fnBase.isLogin(PostDetails.user_id)) {
			//fnBase.toast('亲！您未登陆');
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				GoToLogin();
			} else if(fnBase.versions.android) {
				window.myObj.toLogin();
			}
			return false;
		};
		var _this = $(el);
		var nowTime = new Date().getTime();
		var clickTime = _this.attr("ctime");
		if(clickTime != 'undefined' && (nowTime - clickTime < 3000)) {
			return false;
		} else{
			_this.attr("ctime",nowTime);
		}
		PostDetails.replyThis=_this; //回复的this 对象
		var source = _this.attr('source_id'); //判断是几级回复
		var getArticleUser = $('#getuser').attr('user_id'); //一级回复的文章user_ID
		var parent_id = source == 1 ? 0 : _this.attr('article_reply_id');
		var reply_user_id = source == 1 ? getArticleUser : _this.attr('user_id');
		var reply_user_name = source == 1 ? PostDetails.user_name : _this.attr('user_name');
		//状态    父ID   被回复的user_iD  被回复的user_name
		//console.log(source,parent_id,reply_user_id,reply_user_name)
		weakupkeyboard(source,parent_id,reply_user_id,reply_user_name);
		//PostDetails.getTextareaBox(source,parent_id,reply_user_id,reply_user_name,'5555555')
	}
};

$(document).ready(function() {
	PostDetails.init();
});
window.onload=function(){
	var reply_user_name= fnBase.splitURL()['user_name'];
	var reply= fnBase.splitURL()['reply'];
	if(reply==1){
		weakupkeyboard(1,0,0,reply_user_name);
	}
	
};